<?php
Globals::requireController('Admin');
Globals::requireModel('User');

class LoginController extends AdminController
{
	protected $user;
	
	public function __construct($config = null)
	{
		parent::__construct($config);
		$this->user = new UserModel($config);
		$this->config['layoutEnabled'] = false;
	}
	
	function indexAction()
	{
	}
	
	function postAction()
	{
		$username	= $this->getParam('username');
		$password	= $this->getParam('password');
		$userRow	= $this->user->login($username, $password);
		
		if ($userRow)
		{
			session_start();
			$this->userInfo = $_SESSION['userInfo'] = $userRow;
			$this->log('登录成功');
			$this->redirectToController();
		}
		else Globals::error($this->user->getMessage());
	}
}
